/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.base;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mmanto
 */
@Entity
@Table(name = "barrio")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Barrio.findAll", query = "SELECT b FROM Barrio b"),
    @NamedQuery(name = "Barrio.findById", query = "SELECT b FROM Barrio b WHERE b.id = :id"),
    @NamedQuery(name = "Barrio.findByNombre", query = "SELECT b FROM Barrio b WHERE b.nombre = :nombre"),
    @NamedQuery(name = "Barrio.findByDireccionDeReferencia", query = "SELECT b FROM Barrio b WHERE b.direccionDeReferencia = :direccionDeReferencia")})
public class Barrio implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "nombre")
    private String nombre;
    @Size(max = 255)
    @Column(name = "direccion_de_referencia")
    private String direccionDeReferencia;
    @JoinColumn(name = "partido_id", referencedColumnName = "id")
    @ManyToOne
    private Partido partidoId;
    @JoinColumn(name = "nomenclatura_origen_id", referencedColumnName = "id")
    @ManyToOne
    private NomenclaturaCatastral nomenclaturaOrigenId;
    @JoinColumn(name = "dato_del_dominio_id", referencedColumnName = "id")
    @ManyToOne
    private DatoDelDominio datoDelDominioId;
    @OneToMany(mappedBy = "barrioId")
    private Collection<Expediente> expedienteCollection;

    public Barrio() {
    }

    public Barrio(Integer id) {
        this.id = id;
    }

    public Barrio(Integer id, String nombre) {
        this.id = id;
        this.nombre = nombre;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDireccionDeReferencia() {
        return direccionDeReferencia;
    }

    public void setDireccionDeReferencia(String direccionDeReferencia) {
        this.direccionDeReferencia = direccionDeReferencia;
    }

    public Partido getPartidoId() {
        return partidoId;
    }

    public void setPartidoId(Partido partidoId) {
        this.partidoId = partidoId;
    }

    public NomenclaturaCatastral getNomenclaturaOrigenId() {
        return nomenclaturaOrigenId;
    }

    public void setNomenclaturaOrigenId(NomenclaturaCatastral nomenclaturaOrigenId) {
        this.nomenclaturaOrigenId = nomenclaturaOrigenId;
    }

    public DatoDelDominio getDatoDelDominioId() {
        return datoDelDominioId;
    }

    public void setDatoDelDominioId(DatoDelDominio datoDelDominioId) {
        this.datoDelDominioId = datoDelDominioId;
    }

    @XmlTransient
    public Collection<Expediente> getExpedienteCollection() {
        return expedienteCollection;
    }

    public void setExpedienteCollection(Collection<Expediente> expedienteCollection) {
        this.expedienteCollection = expedienteCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Barrio)) {
            return false;
        }
        Barrio other = (Barrio) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.nombre;
    }
    
}
